<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 导入 layui 的样式 -->
    <link rel="stylesheet" href="../assets/lib/layui/css/layui.css">
    <link rel="stylesheet" href="../assets/css/books-category.css">
</head>

<body>
    <!-- 引用layui结构样式 -->
    <div class="layui-card">
        <div class="layui-card-header">文章类别管理
            <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="add_btn">添加类别</button>
        </div>
        <div class="layui-card-body">
            <table class="layui-table">
                <colgroup>
                    <col width="45%">
                    <col width="40%">
                    <col>
                </colgroup>
                <thead>
                    <tr>
                        <th>分类名称</th>
                        <th>分类别名</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>辣鸡</td>
                        <td>范文芳</td>
                        <td>
                            <button type="button" class="layui-btn layui-btn-xs ">编辑</button>
                            <button type="button" class="layui-btn layui-btn-xs layui-btn-danger">删除</button>
                        </td>
                    </tr>
                    <!-- 这里做动态添加 -->

                </tbody>
            </table>
        </div>
    </div>
    <!--############### 添加表格基础模板 #################-->
    <script type="text/html" id="tr_muBan">
        {{each data val}}
        <tr>
            <td>{{val.name}}</td>
            <td>{{val.alias}}</td>
            <td>
                <button type="button" class="layui-btn layui-btn-xs" id="editor"
                data-id="{{val.Id}}" data-name="{{val.name}}" data-alias="{{val.alias}}">编辑</button>

                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="btn-del"
                data-del="{{val.Id}}">删除</button>
            </td>
        </tr>
        {{/each}}
    </script>
    <!--############### 点击添加，新增表单弹出层 #################-->
    <script type="text/html" id="add_muBan">
        <form class="layui-form add_form" action="" style="padding:15px 30px 0 0" >
            <div class="layui-form-item">
              <label class="layui-form-label">分类名称</label>
              <div class="layui-input-block">
                  <!-- 根据接口文档修改name值 -->
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
              </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">分类别名</label>
                <div class="layui-input-block">
                  <input type="text" name="alias" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
              </div>
              <!-- 按钮 -->
              <button class="layui-btn" lay-submit lay-filter="formDemo" style="margin-left:150px">确认添加</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </form>
    </script>
    <!-- end -->
    <!-- #################### 创建编辑模板 #######################-->
    <script type="text/html" id="editor_muBan">
        <form class="layui-form editor_form" action="" style="padding:15px 30px 0 0" lay-filter="lay">
            <div class="layui-form-item">
              <label class="layui-form-label">分类名称</label>
              <div class="layui-input-block">
                  <!-- 根据接口文档修改name值 -->
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value={{data.name}}>
              </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">分类别名</label>
                <div class="layui-input-block">
                  <input type="text" name="alias" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value={{data.alias}}>
                </div>
              </div>
              <!-- 隐藏域 -->
              <input type="hidden" name="Id" id="" value={{data.Id}}>
              <!-- 按钮 -->
              <button class="layui-btn" lay-submit lay-filter="formDemo" style="margin-left:150px">确认修改</button> 
    </script>

    <!-- 引入js文件 -->
    <script src="../assets/lib/jquery.js"></script>
    <script src="../assets/lib/template-web.js"></script>
    <script src="../assets/js/ajax-prefilter.js"></script>
    <script src="../assets/lib/layui/layui.all.js"></script>
    <script src="../assets/js/books-category.js"></script>

</body>

</html>